package edu.buffalo.cse.cse486_586.simpledht.config;

import java.util.Map;
import java.util.TreeMap;
import edu.buffalo.cse.cse486_586.util.AppUtil;

public class MasterConfiguration {
	private static MasterConfiguration masterConfig = null;
	// all of the alive node contain
	private Map<String, Node> nodeList;
	private Map<String, String> readyPkgContainer;
	private int numDev;

	protected MasterConfiguration() {
		this.numDev = AppUtil.numDev;
		this.nodeList = new TreeMap<String, Node>();
		this.readyPkgContainer = new TreeMap<String, String>();
	}

	public static MasterConfiguration getInstance() {
		if (masterConfig == null) {
			masterConfig = new MasterConfiguration();
		}
		return masterConfig;
	}

	public Map<String, Node> getNodeList() {
		return this.nodeList;
	}

	public void addNode(Node n) {
		this.nodeList.put(n.getHashKey(), n);
	}

	public Map<String, String> getReadyPkgContainer() {
		return this.readyPkgContainer;
	}

	public void addreadyPkg(String key, String pkg) {
		this.readyPkgContainer.put(key, pkg);
	}

	public int getNumDev() {
		return numDev;
	}

	public void setNumDev(int numDev) {
		this.numDev = numDev;
	}
}
